//
//  GQTabBarController.m
//  MyMusic
//
//  Created by sunny on 16/4/2.
//  Copyright © 2016年 sunny. All rights reserved.
//

#import "GQTabBarController.h"
#import "GQMusicLibraryViewController.h"
#import "GQMineViewController.h"

#import "GQNavigationController.h"
@interface GQTabBarController ()

@end

@implementation GQTabBarController


- (void)viewDidLoad {
    [super viewDidLoad];
    
//    添加所有的子控制器
    [self setupAllChildViewControllers];
    
//    设置底部按钮的标题和图片
    [self setupTitleButtons];
    
//    设置底部背景颜色 ->插入一个view
    UIView *backView = [[UIView alloc] initWithFrame:self.tabBar.bounds];
    backView.backgroundColor = [UIColor colorWithRed:0 green:165 / 255.0 blue:244 / 255.0 alpha:1];
    [self.tabBar insertSubview:backView atIndex:0];    

    self.tabBar.clipsToBounds = YES;

}

#pragma mark - 添加所有的子控制器
- (void)setupAllChildViewControllers
{
//    发现音乐
    GQMusicLibraryViewController *findVc = [[GQMusicLibraryViewController alloc] init];
    GQNavigationController *nav1 = [[GQNavigationController alloc] initWithRootViewController:findVc];
    [self addChildViewController:nav1];
    
//    乐库
    GQMineViewController *mineVc = [GQMineViewController  mineViewController];
    GQNavigationController *nav2 = [[GQNavigationController alloc] initWithRootViewController:mineVc];
    [self addChildViewController:nav2];

}

#pragma mark - 设置底部按钮的标题和图片
- (void)setupTitleButtons
{
//    在线音乐（乐库）
    GQNavigationController *nav1 = self.childViewControllers[0];
    nav1.tabBarItem.image = [UIImage imageNamed:@"ic_tabbar_onlinemusic_icon_normal"];
    nav1.tabBarItem.selectedImage = [UIImage imageNameOriginal:@"ic_tabbar_onlinemusic_icon_press"];
    
//    我的
    GQNavigationController *nav2 = self.childViewControllers[1];
//    nav2.title = @"我的";
    nav2.tabBarItem.image = [UIImage imageNamed:@"ic_tabbar_mymusic_icon_normal"];
    nav2.tabBarItem.selectedImage = [UIImage imageNameOriginal:@"ic_tabbar_mymusic_icon_press"];
    
}


@end
